package com.xltq.controller;

import cn.dsna.util.images.ValidateCode;
import com.sun.org.apache.regexp.internal.RE;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//验证码产生的servlet
@WebServlet("/code")
public class CodeController extends BaseServlet {

    public void createCode(HttpServletRequest request,HttpServletResponse response) throws Exception{
        //1.验证码包已经添加完毕直接使用ValidateCode类创建即可
        ValidateCode validateCode = new ValidateCode(100,35,1,20);
        //2.获取验证码
        String code = validateCode.getCode();
        //3.将验证码存储在session作用域中进行用户登录验证使用
        request.getSession().setAttribute("code", code);
        //3.向页面进行响应
        validateCode.write(response.getOutputStream());


    }
}
